/**
 * Created with IntelliJ IDEA.
 * User: seeker910
 * Date: 13-10-13
 * Time: 上午7:04
 * To change this template use File | Settings | File Templates.
 */
Rsd.define('Rsd.Faith.views.MainForm',
    {
        extend: 'Rsd.view.MasterLTC',
        requires: [
            'Rsd.Faith.views.Header',
            'Rsd.Faith.views.MenuTree','Rsd.Faith.views.ListMenu',
            'Rsd.Faith.views.TabPage',
            'Rsd.Faith.views.Footer'
        ],
        xtype:'main_form',
        layout: 'border',
        home: null,
        header:{xtype:'f-header',height:60,align:'left',space:1},
        footer:'f-footer',
        left: {xtype:'home-menu',width:120},//'f-tree',
        top:{ itemStyle:{height:'50px',width:'auto',float:'left',textAlign:'center',marginRight:'5px'},},
        content:'f-tabPage',
        home: {m:'00',f:'0001'},
        /*
         * */
        constructor: function (config) {
            config = config || {};
            Rsd.apply(this, config);

        },
        onAfterShow:function aftershow()
        {
            var me =this;
            this.store = Rsd.create('Rsd.Faith.stores.MenuStore'),
                this.store.load(null, function (menu) {
                  me.left.loadData(menu);
                });
        },
        /*
        *
        * */
        setPageTitle:function setPageTitle(title) {
            this.header.content.setTitle(title);
        },
        /*
        * */
        showPage:function showPage(page,speed) {
            this.callParent(page,speed);
            this.setPageTitle(page.tabTitle);
        },
        /*
        *
        * */
        load:function load() {


            var me = this;
            var m = Rsd.getUrlParam('m');
            var f = Rsd.getUrlParam('f');

            if(!m && !f && !Rsd.isEmpty(me.home))
            {
                Rsd.setUrlParam(me.home);
                return;
            }

            if(m)
            {
                me.left.select(parseInt(m));

            }else
            {
                me.left.select(0);
            }

            if(m && f && f > 0)
            {
                //主窗体 selectMenu 有block延时阻塞
                setTimeout(function () {
                    me.top.select(parseInt(f));
                },2000);
            }

            return this;

        }

    });

